package main

import (
	"backend/Controller"
	"backend/auth"
	_ "backend/docs"
	"backend/util"
	"github.com/gin-gonic/gin"
	"github.com/swaggo/files"
	"github.com/swaggo/gin-swagger"
)

// @title 这里写标题
// @version 1.0
// @description 这里写描述信息
// @termsOfService http://swagger.io/terms/

// @contact.name 这里写联系人信息
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io

// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html

// @host localhost:8888
// @BasePath
func main() {

	util.InitServer()

	r := gin.Default()

	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

	r.Use(auth.Auther())
	chapterController := Controller.ChapterController{}
	curriculumController := Controller.CurriculumController{}
	curriculumSeriesController := Controller.CurriculumSeriesController{}
	dataSpaceController := Controller.DataSpaceController{}
	discussContentController := Controller.DiscussContentController{}
	discussController := Controller.DiscussController{}
	homeWorkController := Controller.HomeWorkController{}
	loginController := Controller.LoginController{}
	userController := Controller.UserController{}
	teacherGroup := r.Group("teacher")
	{
		teacherGroup.POST("setNewHomeWork", homeWorkController.SetNewHomeWork)
		teacherGroup.POST("SetNewCurriculumSeries", curriculumSeriesController.SetNewCurriculumSeries)
		teacherGroup.POST("PutCurriculum", curriculumController.SetNewCurriculum)
		teacherGroup.POST("PutFile", dataSpaceController.PutFile)
		teacherGroup.POST("GetCurriculumsBySeriesId", curriculumController.GetCurriculumsBySeriesId)
		teacherGroup.POST("AddNewChapter", chapterController.AddNewChapter)
		teacherGroup.POST("DelChapter", chapterController.DelChapter)
		teacherGroup.POST("UpdateCurriculumData", curriculumController.UpdateCurriculumData)
		teacherGroup.POST("UpdateChapterData", chapterController.UpdateChapterData)
		teacherGroup.GET("GetHomeWorkFileAndStudentListByHomeWorkId", homeWorkController.GetHomeWorkFileAndStudentListByHomeWorkId)
		teacherGroup.GET("DeleteCourseSeries", curriculumSeriesController.DeleteCourseSeries)
		teacherGroup.GET("DeleteCurriculum", curriculumController.DeleteCurriculum)
		teacherGroup.GET("DeleteHomework", homeWorkController.DeleteHomework)
		teacherGroup.POST("AddNewDiscussTopic", discussController.AddNewDiscussTopic)
		teacherGroup.POST("UpdateDiscussTopic", discussController.UpdateDiscussTopic)
		teacherGroup.GET("DelDiscussTopic", discussController.DelDiscussTopic)
		teacherGroup.POST("AddStudentByExcel", userController.AddStudentByExcel)
		teacherGroup.GET("getStudentList", userController.GetStudentPage)
		teacherGroup.GET("getExcelModel", userController.GetExcelModel)
		teacherGroup.GET("getClassList", userController.GetClassList)
		teacherGroup.GET("GetHomeWorkStuListByClass", userController.GetHomeWorkStuListByClass)
		teacherGroup.GET("GetCurrStuListByClass", curriculumController.GetCurrStuListByClass)
		teacherGroup.GET("GetCurriculumStuListByClass", userController.GetCurriculumStuListByClass)
		teacherGroup.POST("ChangeHomeWorksStu", homeWorkController.ChangeHomeWorksStu)
		teacherGroup.POST("ChangeCurriculumsStu", curriculumController.ChangeCurriculumsStu)
		teacherGroup.GET("GetFileByHomeworkAndStu", userController.GetFileByHomeworkAndStu)
		teacherGroup.POST("SetCurrSeriesIntroduction", curriculumSeriesController.SetCurrSeriesIntroduction)
		teacherGroup.GET("GetStuHomeWorkInfo", homeWorkController.GetStuHomeWorkInfo)
		teacherGroup.GET("GetStuCurrInfo", curriculumController.GetStuCurrInfo)
		teacherGroup.POST("SetScore", homeWorkController.SetScore)
		teacherGroup.GET("PageStudentByClass", userController.PageStudentByClass)
		teacherGroup.GET("DelStudentById", userController.DelStudentById)
		teacherGroup.GET("ChangeStuPasswd", userController.ChangeStuPasswd)
		teacherGroup.POST("PageHomeWorkList", homeWorkController.PageHomeWorkList)
	}
	openGroup := r.Group("open")
	{
		openGroup.POST("GeyCurriculumSeries", curriculumSeriesController.GeyCurriculumSeries)
		openGroup.POST("TeacherLogin", loginController.TeacherLogin)
		openGroup.POST("StudentLogin", loginController.StudentLogin)
		openGroup.POST("CheckLogStatus", loginController.CheckLogStatus)
	}

	{
		r.POST("/GetFileList", dataSpaceController.GetFileList)
		r.POST("/ListCurriculum", curriculumController.ListCurriculum)
		r.POST("/GetHomeWorkList", homeWorkController.GetHomeWorkList)
		r.POST("/StuGetHomeWorkList", homeWorkController.StuGetHomeWorkList)
		r.POST("/GetAllFileList", dataSpaceController.GetAllFileList)
		r.POST("/GetOnlyCurriculumsBySeriesId", curriculumController.GetOnlyCurriculumsBySeriesId)
		r.POST("/GetChapterByCurriculum", chapterController.GetChapterByCurriculum)
		r.GET("/GetDataSpaceFileByUrl", dataSpaceController.GetDataSpaceFileByUrl)
		r.POST("/HomeWorkUpLoadFile", homeWorkController.HomeWorkUpLoadFile)
		r.POST("/GetHomeWorkFileListByStuIdAndHomeWorkId", homeWorkController.GetHomeWorkFileListByStuIdAndHomeWorkId)
		r.GET("/GetHomeWorkFileByUrl/*path", homeWorkController.GetHomeWorkFileByUrl)
		r.GET("/GetHomeWorkFileAndStudentListById", homeWorkController.GetHomeWorkFileAndStudentListById)
		r.GET("/WithdrawHomework", homeWorkController.WithdrawHomework)
		r.GET("/StudentChangePassword", userController.StudentChangePassword)
		r.GET("/PageDiscussTopic", discussController.PageDiscussTopic)
		r.GET("/ListDiscussTopic", discussController.ListDiscussTopic)
		r.POST("/AddComments", discussContentController.AddComments)
		r.GET("/PageComments", discussContentController.PageComments)
		r.GET("/PageRepListByCommentId", discussContentController.PageRepListByCommentId)
		r.POST("/AddRep", discussContentController.AddRep)
	}

	_ = r.Run(":8888")
}
